import { mix } from "@/utils/mix";

export { buttonGenerate } from "./compVarGenerate/buttonGenerate";
export { linkButtonGenerate} from "./compVarGenerate/linkButtonGenerate";
export { tagGenerate } from "./compVarGenerate/tagGenerate";

export const generateWeight = () => {
  return Array.from(new Array(9)).map((_, index) => (index + 1) * 10);
}

const primarySeriesGenerate = (result, white, primary) => {
  const primarySeriesWeight = generateWeight();
  result['--color-primary'] = primary

  primarySeriesWeight.forEach((weight, index) => {
    result[`--color-primary-light-${index + 1}`] = mix(white, primary, weight)
  })
}

const colorsLighterGenerate = (result, white, colors, weights) => {
  Object.entries(colors).forEach(([colorKey, color]) => {
    result[`--color-${colorKey}`] = color;

    Object.entries(weights).forEach(([prefix, weight]) => {
      result[`--color-${colorKey}-${prefix}`] = mix(white, color, weight)
    })
  })
}

/**
 *
 * @param {{black: string, white: string, primary: string, success: string, danger: string, warning: string, info: string}} colors
 * @return {{a: string}}
 */
export const generateTheme = (colors) => {
  const { white, primary, success, danger, warning, info } = colors;
  const result = {}

  primarySeriesGenerate(result, white, primary);
  colorsLighterGenerate(result, white,{ success, danger, warning, info }, { light: 80, lighter: 90 });

  return result;
}
